package test;

import com.codahale.metrics.ConsoleReporter;
import com.codahale.metrics.Histogram;
import com.codahale.metrics.Meter;
import com.codahale.metrics.MetricRegistry;

import java.util.concurrent.TimeUnit;

public class PerformanceAnalyze {

    final MetricRegistry metrics = new MetricRegistry();
    private final Meter meter = metrics.meter("meter");
    private final Histogram delay = metrics.histogram("delay");
    private final Histogram length = metrics.histogram("length");

    ConsoleReporter reporter = ConsoleReporter.forRegistry(metrics).build();

    public PerformanceAnalyze() {
        reporter.start(5, TimeUnit.SECONDS);
    }


    public void meter() {
        meter.mark();
    }

    public void delay(long update) {
        delay.update(update);
    }

    public void length(long update) {
        length.update(update);
    }

    public Meter getMeter() {
        return meter;
    }


}
